$(function(){
	$('#changPass').on('tap',function(){
		//trim用于判断空格
		var originPass = $.trim($("[name='originPass']").val());
		var newPass = $.trim($("[name='newPass']").val());
		var confirmNewPass = $.trim($("[name='confirmNewPass']").val());
		var vCode = $.trim($("[name='vCode']").val());
		if(!originPass){
            mui.toast("请输入正确的用户名");           
        } 
        if(!newPass){
            mui.toast("请输入正确的密码");           
        } 
         if(!confirmNewPass || confirmNewPass!=newPass){
            mui.toast("请输入正确的确定密码");           
        } 
         if(!vCode){
            mui.toast("请输入正确的验证码");           
        } 
		//调用接口获取更改密码
		$.ajax({
			url:'/user/updatepassword',
			type:'post',
			data:{
				oldPassword:originPass,
				newPassword:newPass,
				vCode:vCode
			},
			success:function(res){
				console.log(res);
				if(res.success){
					mui.toast("修改成功");
					setTimeout(function(){
						location.href="login.html";
					},1000)
				}
			}
		});
	});
	$('.getCode').on('click',function(){
		//获取验证码
		$.ajax({
			url:'/user/vCodeForUpdatePassword',
			type:'get',
			success:function(res){
				vCode = res.vCode;
				console.log(vCode);
			}
		});
	});
	
});










